home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / patches / pgs3h1.lha / 3.0hUpdate / Macros.LHA / SendtoBME.rexx < prev    next >
OS/2 REXX Batch file  |  1995-06-28  |  4KB  |  136 lines

  1. /* $VER: SendtoBME.rexx 2.0 (28.06.95)
  2.    Copyright 1995 Soft-Logik Publishing Corporation
  3.    May not be distributed without Soft-Logik Publishing Corporation's express written permission */
  4.  
  5. OPTIONS RESULTS
  6. TRACE OFF
  7.  
  8. /* Make sure rexx support is opened */
  9. IF ~SHOW('L','rexxsupport.library') THEN
  10.    CALL ADDLIB('rexxsupport.library',0,-30)
  11.  
  12. ADDRESS 'PAGESTREAM'
  13.  
  14. /* Check and see if one picture is selected */
  15. getobject type objtype
  16. if objtype~=12 then do
  17.     ADDRESS 'PAGESTREAM'
  18.     allocarexxrequester '"Send to Editor Error!"' 368 59
  19.     reqhandle=result
  20.     addarexxgadget reqhandle EXIT 286 42 70 label "_Exit"
  21.         Exithandle=result
  22.     addarexxgadget reqhandle TEXT 8 10 352 border none string "'One picture must be selected to edit in BME.'"
  23.     addarexxgadget reqhandle TEXT 8 20 352 border none string "'Select only one picture and try again.'"
  24.     doarexxrequester reqhandle
  25.     freearexxrequester reqhandle
  26.     EXIT
  27. end
  28.  
  29. /* Stop the user from messing things up while away */
  30. 'lockinterface true'
  31.  
  32. /* Export the picture to a temp file if internal */
  33. 'getpicture fileinfo fstem'
  34. /* Append PageStream3: if not a full path */
  35. if pos(':',fstem.file)=0 then fstem.file='PageStream3:'||fstem.file
  36. /* If imported from ram file, fix the space problem with ram disk */
  37. if left(fstem.file,9)='Ram Disk:' then fstem.file='Ram:'||right(fstem.file,length(fstem.file)-9)
  38. filepath=fstem.file
  39. if pos('/',filepath)~=0 then filename=right(filepath,length(filepath)-lastpos('/',filepath))
  40. else filename=right(filepath,length(filepath)-lastpos(':',filepath))
  41. /* If untitled, then give it a name */
  42. if fstem.file='PageStream3:' then filename='UntitledPicture'
  43. if fstem.mode=INTERNAL then do
  44.     filepath='t:'filename
  45.     'exportgraphic file 'filepath' filter iffilbm status force'
  46. end
  47.  
  48. 'refresh wait'
  49.  
  50. /* Set the default BME path */
  51. bmepath='PageStream3:BME'
  52. preffile='PageStream3:SendtoBME.prefs'
  53.  
  54. /* If BME doesn't exist in the default path, check SendtoBME.prefs */
  55. if ~exists(bmepath) then do
  56.     if open(.ifile, preffile, 'R') then do
  57.         bmepath=readln(.ifile)
  58.         call close(.ifile)
  59.         askuser='no'
  60.         end
  61.     else do
  62.         askuser='yes'
  63.     end
  64.     /* If BME doesn't exist in the set pref path, ask the user where it is */
  65.     if ~exists(bmepath) | askuser='yes' then do
  66.         getfile TITLE "'Please locate BME'" load path "'PageStream3:'" file BME posbutton 'Ok' negbutton 'Cancel'
  67.         if RC=10 then signal cancel
  68.         bmepath=result
  69.         if open(.ifile, preffile, 'W') then do
  70.             call writeln(.ifile, bmepath)
  71.             call close(.ifile)
  72.         end
  73.     end
  74. end
  75.  
  76.  
  77. /* Run BME */
  78. ADDRESS COMMAND
  79. 'run >nil:' bmepath
  80.  
  81. /* Wait until the ARexx port shows up */
  82. do 20
  83.     if ~show(P, 'BME') then call delay(50)
  84. end
  85.  
  86. /* If the ARexx port didn't show up, alert the user and exit */
  87. if ~show(P, 'BME') then do
  88.     ADDRESS 'PAGESTREAM'
  89.     allocarexxrequester '"Send to Editor Error!"' 368 59
  90.     reqhandle=result
  91.     addarexxgadget reqhandle EXIT 286 42 70 label "_Exit"
  92.         Exithandle=result
  93.     addarexxgadget reqhandle TEXT 8 10 352 border none string "'BME could not be started.'"
  94.     doarexxrequester reqhandle
  95.     freearexxrequester reqhandle
  96.     'refresh continue'
  97.     'lockinterface false'
  98.     EXIT
  99. end
  100.  
  101. ADDRESS 'BME'
  102. 'screentofront'
  103. 'open 'filepath
  104.  
  105. /* Wait for the user to finish in BME */
  106. do forever
  107.     if show(P, 'BME') then do
  108.         'getpicture 'filepath
  109.         if rc=0 then call delay(50)
  110.         else signal update
  111.     end
  112.     else signal update
  113. end
  114.  
  115. /* Update PageStream and exit */
  116. UPDATE:
  117. ADDRESS 'PAGESTREAM'
  118. 'screentofront'
  119. 'revealwindow current'
  120. 'editpicture internal'
  121. 'editpicture external file 'filepath
  122. if fstem.mode=INTERNAL then 'editpicture internal'
  123. else 'editpicture external file 'fstem.file
  124. signal cancel
  125.  
  126.  
  127.  
  128. CANCEL:
  129. ADDRESS 'PAGESTREAM'
  130. 'refresh continue'
  131. 'lockinterface false'
  132. ADDRESS COMMAND
  133. /*'delete t:'filename' >NIL:'*/
  134. 'delete t:'filename
  135. EXIT
  136.